import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

public class Demo02 {
    /*
    1.将一个字符串，转换为Date。将一个Date转换为 2023-10-23 10:01:02这种格式。
    2.创建一个学生数组，学生数组中有生日，要求类型是Date。创建一组学生，并且放入生日。
    创建4个学生，并且放入。
    zs 18 hubei "2023-10-02"
    ls 17 beijing "2022-11-02"
    wu 19 hubei "2021-09-02"
    zl 21 tianjin "2009-10-02"
     */
    public static void main(String[] args) throws ParseException {
        Object o = new Object();

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Student2[] student2s = new Student2[4];
        student2s[0] = new Student2("zs",18,"hubei",sdf.parse("2023-10-02"));
        student2s[1] = new Student2("ls",17,"beijing",sdf.parse("2022-11-02"));
        student2s[2] = new Student2("wu",19,"hubei",sdf.parse("2021-09-02"));
        student2s[3] = new Student2("zl",21,"tianjin",sdf.parse("2009-10-02"));
        for (int i = 0; i < student2s.length; i++) {
            System.out.println(student2s[i]);
        }

    }
}
class Student2 {
    static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    private String name;
    private int age;
    private String address;
    private Date date;


    public Student2() throws ParseException {
    }

    @Override
    public String toString() {
        return "Student2{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", address='" + address + '\'' +
                ", date=" + sdf.format(date) +
                '}';
    }
    public Student2(String name, int age, String address, Date date) throws ParseException {
        this.name = name;
        this.age = age;
        this.address = address;
        this.date = date;
    }

}
